#ifndef BADMINTON_H
#define BADMINTON_H

#include <QObject>
#include<QTimer>
#include <Qpixmap>
#include <QGraphicsPixmapItem>
#include "player1.h"  // 添加玩家类头文件
#include "player2.h"  // 添加玩家类头文件
#include <QGraphicsItemGroup>
#include "racket.h"
#include <QSoundEffect>

class Badminton : public QObject , public QGraphicsPixmapItem
{
    Q_OBJECT
public:
    explicit Badminton(QObject *parent1 = nullptr,QGraphicsItem *parent = nullptr);
    QTimer* GameTimer;//羽毛球计时器
    double Vx;
    double Vy;//x,y轴速度
    double Gravity;
    ~Badminton();
    
    void setPlayers(Player1* p1, Player2* p2);
    void setAirWall(QGraphicsRectItem *AirWall1,QGraphicsRectItem *AirWall2,QGraphicsRectItem *AirWall3);    // 新增设置玩家方法
    
public slots:
    void move();
    
public:
    Player1* player1 = nullptr;  // 新增玩家指针
    Player2* player2 = nullptr;  // 新增玩家指针
    QGraphicsRectItem *airWall1;
    QGraphicsRectItem *airWall2;
    QGraphicsRectItem *airWall3;
    bool checkRacketCollision(Racket* racket);  // 新增碰撞检测方法
    bool checkAirWallCollision(QGraphicsRectItem *AirWall);
    QSoundEffect m_beatSound; //击球声音
signals:
    void landed();  // 羽毛球落地信号
};

#endif // BADMINTON_H
